package com.ava.avamedia.lottery;

import com.ava.avamedia.R;
import com.ava.avamedia.adapter.RegionAdapter;
import com.ava.avamedia.util.Constants;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class RegionActivity extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_region);
		ListView listView = (ListView) findViewById(R.id.activity_region_list_view);
		RegionAdapter adapter = new RegionAdapter(this);
		listView.setAdapter(adapter);
		listView.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				startActivity(arg2);
			}
		});
	}

	public void startActivity(int index) {
		if (index == 0) {
			Intent intent = new Intent();
			intent.setClass(RegionActivity.this, MenuActivity.class);
			intent.putExtra(Constants.REGION, index);
			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
		}else{
			Intent intent = new Intent();
			intent.setClass(RegionActivity.this, ListCitiesActivity.class);
			intent.putExtra(Constants.REGION, index);
			intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
		}
	
	}
}
